package com.allenkerr.util;

import com.allenkerr.enums.ResultEnum;
import com.allenkerr.vo.Result;

/**
 * Created by 小柯 on 17/6/19.
 */
public class ResultUtils {

    private ResultUtils() {
    }

    /**
     * 成功，带 data 返回
     */
    public static Result success(ResultEnum resultEnum, Object data) {
        return new Result(resultEnum.getCode(), resultEnum.getMsg(), data);
    }

    /**
     * 成功，不带data返回
     */
    public static Result success(ResultEnum resultEnum) {
        return success(resultEnum, null);
    }

    /**
     * 失败，带 data 返回
     */
    public static Result fail(ResultEnum resultEnum, Object data) {
        return new Result(resultEnum.getCode(), resultEnum.getMsg(), data);
    }

    /**
     * 失败，不带 data 返回
     */
    public static Result fail(ResultEnum resultEnum) {
        return fail(resultEnum, null);
    }
}
